﻿#include <iostream>
#include<string>
using namespace std;
void replacestring(string& str, const string& oldstr, const string& newstr) {
    int p = 0;
    while (str.find(oldstr, p) != string::npos) {
        str.replace(p, oldstr.size(), newstr);
        p += newstr.size();
    }
}
int main()
{
    string s = "thu tho thu";
    replacestring(s, "thu", "through");
}


